/**
 * Created by chaoCheng on 2017/1/13.
 */
angular.module('group', [])//模块名，注入到admin 主模块中
    .config(function GroupRoutes($stateProvider) {
        $stateProvider
            .state('grouplist',{
                parent:'admin',
                url: '/grouplist?{groupName:string}',
                params: {
                    page: { value: 1, squash: true },//初始化url中的参数，不需要可以不写
                    size: { value: 2, squash: true }
                },
                views: {
                    'main@admin': {
                        templateUrl: 'admin/plan/grouplist.html',//html地址
                        controller: 'GroupController as vm',//控制器和他的别名
                        resolve: {
                            initialList: function(Group, $stateParams) {//从后台预加载的数据,Demo-注入的service
                                return Group.searchGroup({
                                    groupName : $stateParams.groupName,
                                    pageInfo: {
                                        pageSize: $stateParams.size,
                                        pageNumber: $stateParams.page
                                    }
                                })
                            }
                        }
                    }
                }
            })
    })

    .service('Group', GroupModel)//声明

    .controller('GroupController', GroupController)
    .controller('planGroupAddCtrl', function ($scope, $uibModalInstance) {
        $scope.ok = function () {
            $uibModalInstance.close('ok');
        };
        $scope.cancel = function () {
            $uibModalInstance.close('cancel');
        };
    })
    .controller('PlayPlanInstanceCtrl', function ($scope, $uibModalInstance) {
        $scope.ok = function () {
            $uibModalInstance.close('ok');
        };
        $scope.cancel = function () {
            $uibModalInstance.close('cancel');
            //$uibModalInstance.dismiss('cancel');
        };
    });
